package net.mingsoft.report_data.util;

import lombok.extern.slf4j.Slf4j;
import net.mingsoft.report_data.enums.ReportPeriodType;

import java.lang.reflect.Method;

/**
 * @author gengfa
 * @date 22/05/30
 */
@Slf4j
public class ReportReflectUtil {

    private static final String GENERATE_METHOD = "generate";

    private ReportReflectUtil() {}

    public static Object generate(Object o, Object... args) {
        Class<?> serviceClass = o.getClass();
        Object result = null;
        try {
            Method method = serviceClass.getDeclaredMethod(GENERATE_METHOD, ReportPeriodType.class);
            result = method.invoke(o, args);
        } catch (Exception e) {
            log.info(e.toString(), e.getMessage());
        }
        return result;
    }
}
